import gobject, dbus, dbus.service, dbus.mainloop.glib

class DemoException(dbus.DBusException):
    _dbus_error_name = 'com.example2.DemoException'

class SomeObject(dbus.service.Object):
    interface = "com.example2.SampleInterface"

    @dbus.service.method(interface, in_signature='s', out_signature='as')
    def HelloWorld(self, hello_message):
        print (str(hello_message))
        return ["Hola", " from example.py",
           "with unique name",
           session_bus.get_unique_name()]

if __name__ == '__main__':
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus()
    service = "com.example2.SampleService"
    name = dbus.service.BusName(service, session_bus)
    object = SomeObject(session_bus, '/SomeObject')
    mainloop = gobject.MainLoop()
    print "Running example service."
    mainloop.run()
